﻿using MediatR;
using SheepCultivation.API.AddliCation.EnterPriseW;
using SheepCultivation.Common.Domain.SheepBasicInformation;
using SheepCultivation.Common.Dto;
using SheepCultivation.Common.Infrastructure.Interface;
using SheepCultivation.Enum;

namespace SheepCultivation.API.AddliCation.SheepFile
{
    public class BasicInformationSeachHandler : IRequestHandler<BasicInformationSeachCommon, Result>
    {
        public readonly IBaseRepository<BasicInformation> BasicInformationRepsoitory;

        public BasicInformationSeachHandler(IBaseRepository<BasicInformation> basicInformationRepsoitory)
        {
            BasicInformationRepsoitory = basicInformationRepsoitory;
        }

        public async Task<Result> Handle(BasicInformationSeachCommon request, CancellationToken cancellationToken)
        {
            var res = new Result() { Code = (int)CommonEnumCode.error };
            try
            {
                var list = BasicInformationRepsoitory.GetAll().ToList();
                res.Code = (int)CommonEnumCode.success;
                res.Data = list;
                res.Msg = "基本信息列表展示";
            }
            catch (Exception)
            {

                throw;
            }

            return res;
        }
    }
}
